Ext.onReady(function() {

	
	// 获取旧密码输入框对象
	var oldpwd = Ext.get('oldPass');
	oldpwd.dom.onmouseout = function() {
		var old = oldpwd.dom.value;
		if (old == '' || old == null) {
			return;
		}
		Ext.Ajax.request({
			url : 'validatePassword',
			params : {
				password : old
			},
			success : function(response) {
				var s = response.responseText;
				if (s == 'success') {
					Ext.get('pwdwrong')
					.applyStyles('display:none;');
					Ext.get('pwdcorrect')
							.applyStyles('display:block;');
				}
				else {
					Ext.get('pwdcorrect')
					.applyStyles('display:none;');
					Ext.get('pwdwrong')
					.applyStyles('display:block;');
				}							
			},
			failure : function() {
				alert('failure');
			}
		});
	};
	
	//修改密码
	// 获取旧密码输入框对象
	var updatepwd = Ext.get('updatepwd');
	var first = Ext.get('first');
	var second = Ext.get('second');
	updatepwd.dom.onmouseover = function() {
		if(first.dom.value !=second.dom.value) {
			alert("两次密码输入不一致！");
			return;
		}
	};
	updatepwd.dom.onclick = function() {
		Ext.Ajax.request({
			url : 'a_updatePassword',
			params : {
				password : first.dom.value
			},
			success : function(response) {
				var s = response.responseText;
				if (s == 'success') {
					alert("修改成功，请重新登录！");
					window.location = 'logout';
				}
				else {
					alert("修改失败，请重试！");
				}							
			},
			failure : function() {
				alert('failure');
			}
		});
	};
		
	
});
		
	